package factories;

import helpers.Filter;

/**
 * Constructs useful filters for edge detection
 * @author benjamin
 	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
public class FilterFactory {
	/**
	 * Creates a custom filter
	 * @param data 2 dimensional filter coefficients
	 * @param w width of filter
	 * @param h height of filter
	 * @param cX center tap (X) of the filter
	 * @param cY center tap (Y) of the filter
	 * @return custom filter
	 */
	public static Filter createFilter(float[][] data, int w, int h, int cX, int cY){
		return new Filter(data,w,h,cX,cY);
	}
	/**
	 * Creates an edge enhancement filter
	 * @return edge enhancement filter (3x3 matrix)
	 */
	public static Filter createEdgeFilter(){
		final float filterSpec[][] = {{-1, -1, -1},
				  					  {-1, +8, -1},
				  					  {-1, -1, -1}};
		return new Filter(filterSpec,3,3,1,1);
	}
	/**
	 * Creates a subtle sharpening filter
	 * @return sharpening filter (5x5 matrix)
	 */
	public static Filter createSharpenFilter(){
		final float filterSpec[][] = {{-1, -1, -1, -1, -1},
			    					  {-1,  2,  2,  2, -1},
			    					  {-1,  2,  8,  2, -1},
			    					  {-1,  2,  2,  2, -1},
			    					  {-1, -1, -1, -1, -1}};
		return new Filter(filterSpec,5,5,2,2);
	}
}
